<?php


namespace gzapi\common\model;


use think\Db;
use think\Model;

class GzHiseFollowModel extends Model
{
    protected $prefix = 'cmf_';
    protected $autoWriteTimestamp = true;
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';

    //获取工程列表
    /*$type   未开工，安装，运行，保外
     *$follow  关注
     *
     * */
    public function list($where = [])
    {
        $data = self::alias('hise')
            ->where($where)
            ->select()
            ->toArray();
        return $data;
    }

    //获取数量
    public function num($where = [])
    {
        $num = self::alias('hise')
            ->where($where)
            ->count();
        return $num;
    }


    //更新数据
    public function updates($where,$data)
    {
        $result = self::where($where)->update($data);
        return $result;
    }

    //添加
    public function add($data)
    {
        $is = $this->getOne($data);
        if($is)
        {
            return 0;
        }else{
            self::data($data);
            return self::save();
        }
    }
    //删除
    public function del($where)
    {
        return self::where($where)->delete();
    }

    //查询
    public function getOne($where)
    {
        $data = self::where($where)->find();
        return $data;
    }
}